<#include "/common/include.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="新增任务"/>
<@addorEdit fromId="form-job-add">
			<div class="form-group">
				<label class="col-sm-3 control-label">任务名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="jobName" id="jobName" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">任务分组：</label>
				<div class="col-sm-8">
					<select name="jobGroup" class="form-control m-b">
						<#list dict.getType('sys_job_group')>
							<#items as d>
								<#if d.status =='0' >
									<option value="${d.dictValue}" text="${d.dictLabel}" <#if d.isDefault =='Y' >checked</#if>>${d.dictLabel}</option>
								</#if>
							</#items>
						</#list>
		            </select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">SpringBean：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="beanName" id="beanName" required>
				    <span class="help-block m-b-none"><i class="fa fa-info-circle" style="color: orange"></i> SpringBean 调用示例：@Component("heartbeatTask") 填写 heartbeatTask</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">方法名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="methodName" id="methodName" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">参数：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="params" id="params">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">cron表达式：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="cronExpression" id="cronExpression" required>
					<span class="help-block m-b-none"><i class="fa fa-info-circle" style="color: orange"></i>表达式: 0 */5 * * * ?</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<#list dict.getType('sys_job_status')>
						<#items as d>
							<#if d.status =='0' >
								<div class="radio-box">
									<input type="radio" id="${d.dictCode}" name="status"
										   value="${d.dictValue}"  <#if d.isDefault =='Y' >checked</#if>>
									<label  text="${d.dictLabel}">${d.dictLabel}</label>
								</div>
							</#if>
						</#items>
					</#list>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark" class="form-control"></textarea>
				</div>
			</div>
</@addorEdit>
<@footer>
	<script type="text/javascript">
		var prefix = baseURL + "sys/schedule";
	
		$("#form-job-add").validate({
			onkeyup: false,
			rules:{
				cronExpression:{
					remote: {
	                    url: prefix + "/checkCronExpressionIsValid",
	                    type: "post",
	                    dataType: "html",
	                    data: {
	                        "cronExpression": function() {
	                            return opt.common.trim($("#cronExpression").val());
	                        }
	                    },
	                    dataFilter: function(data, type) {
							return opt.validate.unique(data);
	                    }
	                }
				},
			},
			messages: {
	            "cronExpression": {
	                remote: "表达式不正确"
	            }
	        },
	        focusCleanup: true
		});
		
		function submitHandler() {
	        if (opt.validate.form()) {
	        	opt.operate.save(prefix + "/add", $('#form-job-add').serialize());
	        }
	    }
	</script>
</@footer>
</@pageTheme>
